//
//  ReportTableViewCell.m
//  OutesIOS
//
//  Created by norman on 2019/7/6.
//  Copyright © 2019 norman. All rights reserved.
//

#import "ReportTableViewCell.h"

#define CELL_PADDING_LR 15
#define CELL_PADDING_TB 5

@interface ReportTableViewCell()

@property (nonatomic,strong)UIView *bgView;

@property (nonatomic,strong)UILabel *lbName;

@property (nonatomic,strong)UILabel *lbDateTime;

@property (nonatomic,strong)UILabel *lbBuildings;

@end

@implementation ReportTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupViews];
    }
    return self;
}

- (void)setupViews {
    self.contentView.backgroundColor = UIColor16(0xeeeeee);
    
    self.bgView = [[UIView alloc]initWithFrame:CGRectMake(CELL_PADDING_TB, CELL_PADDING_TB, kScreen_Width - 2*CELL_PADDING_TB, 0)];
    self.bgView.backgroundColor = [UIColor whiteColor];
    self.bgView.layer.cornerRadius = 4;
    //阴影效果
    //    self.bgView.layer.shadowColor = UIColor16(0x000000).CGColor;
    //    self.bgView.layer.shadowOffset = CGSizeMake(2, 4);
    //    self.bgView.layer.shadowOpacity = 0.5;
    //    self.bgView.layer.shadowRadius = 4;
    [self.contentView addSubview:self.bgView];
    
    //编辑图标
    UIImageView *edit = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"edit"]];
    edit.x = self.bgView.width - edit.width - CELL_PADDING_LR;
    //    [self.bgView addSubview:edit];
    
    //名称
    self.lbName = [UILabel labelSingleLineFontSize:kListTitleFontSize content:@"报表名称"];
    self.lbName.textColor = BSBlackTextColor;
    self.lbName.x = CELL_PADDING_LR;
    self.lbName.y = CELL_PADDING_LR;
    self.lbName.width = kScreen_Width - 2*CELL_PADDING_LR;
    edit.centerY = self.lbName.centerY;
    [self.bgView addSubview:self.lbName];
    
    UILabel *lb1 = [UILabel labelSingleLineFontSize:kActionBarFontSize content:@"创建日期："];
    lb1.textColor = CM_TABLE_DETAIL_COLOR;
    lb1.x = CELL_PADDING_LR;
    lb1.y = CGRectGetMaxY(self.lbName.frame) + CELL_PADDING_LR;
    [self.bgView addSubview:lb1];
    
    self.lbDateTime = [UILabel labelSingleLineFontSize:kActionBarFontSize content:@"张国其"];
    self.lbDateTime.width = kScreen_Width - CELL_PADDING_LR - CGRectGetMaxX(lb1.frame);
    self.lbDateTime.textColor = CM_TABLE_TITLE_COLOR;
    self.lbDateTime.x = CGRectGetMaxX(lb1.frame) + 2;
    self.lbDateTime.y = CGRectGetMaxY(self.lbName.frame) + CELL_PADDING_LR;
    [self.bgView addSubview:self.lbDateTime];
    
    UILabel *lb4 = [UILabel labelSingleLineFontSize:kActionBarFontSize content:@"包含建筑："];
    lb4.textColor = CM_TABLE_DETAIL_COLOR;
    lb4.x = CELL_PADDING_LR;
    lb4.y = CGRectGetMaxY(self.lbDateTime.frame) + CELL_PADDING_LR;
    [self.bgView addSubview:lb4];
    
    self.lbBuildings = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(lb4.frame) + 2, lb4.y, 0, 0)];
    self.lbBuildings.textColor = CM_TABLE_TITLE_COLOR;
    self.lbBuildings.font = [UIFont systemFontOfSize:kActionBarFontSize];
    self.lbBuildings.size = [Tools sizeOfSingleLineText:@"13671036827" withSize:kActionBarFontSize];
    self.lbBuildings.width = kScreen_Width - CELL_PADDING_LR - CGRectGetMaxX(lb4.frame);
    self.lbBuildings.text = @"13671036827";
    [self.bgView addSubview:self.lbBuildings];
    
    self.bgView.height = CGRectGetMaxY(self.lbBuildings.frame) + CELL_PADDING_LR;
}

+ (CGFloat)cellHeight {
    CGFloat h = 2*CELL_PADDING_TB;
    h += 3*(CELL_PADDING_LR + [Tools sizeOfSingleLineText:@"高度" withSize:kActionBarFontSize].height) + CELL_PADDING_LR;
    return h;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
